<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>

<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>问答系统首页</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="stylesheet" href="../res/layui/css/layui.css">
		<link rel="stylesheet" href="../res/css/global.css">
		<link href="//unpkg.com/layui@2.9.8/dist/css/layui.css" rel="stylesheet">
		<script src="../res/layui/layui.js"></script>
		<script src="../js/jquery.min.js"></script>

	</head>
	<style>
		#retie {
			position: relative;
			right: -390px;
		}
		#gonggao {
			position: relative;
			left: -52px;
		}
	</style>
	<body>

<%--		<iframe  src="head.html" scrolling="no" width="100%" height="65px" ></iframe>--%>
		<jsp:include page="/WEB-INF/jsp/head.jsp"></jsp:include>

		<div class="main layui-clear">
			<div id="gonggao" class="edge">
				<dl class="fly-panel fly-list-one">
					<dt class="fly-panel-title" font-size: 100px ><center>官方通告</center></dt>
						<dd>
							<p>${announcement.concent}</p>
						</dd>

				</dl>
			</div>
			<div class="wrap">
				<div class="content" style="margin-right:0">
					<div class="fly-tab">
						<!--
        <span>
          <a href="" class="tab-this">全部</a>
          <a href="">未结帖</a>
          <a href="">已采纳</a>
          <a href="">置顶帖</a>
          <a href="../user/index.html">我的帖</a>
        </span>
       -->
						<form action="${pageContext.servletContext.contextPath}/index" method="post" accept-charset="UTF-8" class="fly-search">
							<i class="iconfont icon-sousuo"></i>
							<input class="layui-input" autocomplete="off" placeholder="搜索内容" type="text" value="${title}" name="title">
							<input type="submit" value="查询">
						</form>
<%--				javascript:;屏蔽a标签的默认跳转		--%>
						<a href="javascript:;" onclick="publish()" class="layui-btn jie-add">发布问题</a>
					</div>

					<c:if test="${questionList != null}">
						<ul class="fly-list">
							<c:forEach items="${questionList}" var="question">
								<li class="fly-list-li">
<%--									<a href="${pageContext.servletContext.contextPath}/pages/userHome.html?uid=${question.user.uid}" class="fly-list-avatar">--%>
									<a href="javascript:" onclick="cook(${question.user.uid})" class="fly-list-avatar">
										<img src="${question.user.avatar}" alt="">
									</a>
									<h2 class="fly-tip">
										<a href="${pageContext.servletContext.contextPath}/ques/detail?qid=${question.qid}">${question.title}</a>
										<c:if test="${question.isUp == 1}">
										<span class="fly-tip-stick">
											置顶
										</span></c:if>
									</h2>
									<p>
										<span><a href="">${question.user.nickname}</a></span>
										<span>
											<th><fmt:formatDate value="${question.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/></th>
										</span>
										<span class="fly-list-hint">
              								<i class="iconfont" title="回答">&#xe60c;</i> ${question.answerCount}
            							</span>
									</p>
								</li>
							</c:forEach>
						</ul>
					</c:if>


					<c:if test="${questionList == null}">
						<div class="fly-none">并无相关数据</div>
					</c:if>







					<div style="text-align: center">
						<div class="laypage-main">
                            <c:if test="${currentPage != 1}">
                                <a href="${pageContext.servletContext.contextPath}/index?page=${currentPage - 1}" class="laypage-next">上一页</a>
                            </c:if>
                            <a href="${pageContext.servletContext.contextPath}/index?page=1" class="laypage-last" title="首页">首页</a>
                            <c:forEach begin="1" end="${totalPage}" var="page">
                                <a class="${currentPage == page ? 'laypage-curr' : ''}" href="${pageContext.servletContext.contextPath}/index?page=${page}">${page}</a>
                            </c:forEach>
							<span>…</span>
							<a href="${pageContext.servletContext.contextPath}/index?page=${totalPage}" class="laypage-last" title="尾页">尾页</a>
                            <c:if test="${currentPage != totalPage}">
                                <a href="${pageContext.servletContext.contextPath}/index?page=${currentPage + 1}" class="laypage-next">下一页</a>
                            </c:if>
						</div>
					</div>

				</div>
			</div>
			<div id="retie" class="edge">
				<dl class="fly-panel fly-list-one">
					<dt class="fly-panel-title">最近热帖</dt>
						<c:forEach items="${questionUpList}" var="question">
							<dd>
								<a href="${pageContext.servletContext.contextPath}/ques/detail?qid=${question.qid}">${question.title}</a> <span><i
								class="iconfont">&#xe60b;</i>6087</span>
							</dd>
						</c:forEach>

				</dl>

				<dl class="fly-panel fly-list-one">
					<dt class="fly-panel-title">近期热议</dt>
						<c:forEach items="${questionList}" var="question">

							<c:if test="${question.answerCount >= 5}">
								<dd>
									<a href="${pageContext.servletContext.contextPath}/ques/detail?qid=${question.qid}">${question.title}</a> <span>
									<i class="iconfont">&#xe60c;</i>${question.answerCount}</span>
								</dd>
							</c:if>

						</c:forEach>
				</dl>
			</div>
		</div>
	</body>
<script>
	function cook(uid) {
		sessionStorage.setItem("id", uid);
		window.location.href = "${pageContext.servletContext.contextPath}/pages/userHome.html";
	}
	function publish() {
		var user = "${user}";
		if (user == ""){
			// var layer = layui.layer;
			// layer.alert('对话框内容');
			alert("请先登录!");

		}else {
			window.location.href = "${pageContext.servletContext.contextPath}/ques/form";
		}
	}
</script>
</html>
